<!DOCTYPE HTML>
<html>
<head>
    <title>Error</title>
    <link rel="stylesheet" href="/stylesheets/style.css">
    <script src="/scripts/jquery.min.js"></script>
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
    <script src="/scripts/miniui/miniui.js"></script>
</head>
<body>
<div id="form1" style="margin: 0 auto">
    <span style="width:80px;display:inline-block;">退款金额：</span>
    <input id="refundFee" name="refundFee" class="mini-textbox" style="width:155px;"  value='<%= result.data[0].refundFee %>'/>

    <span style="width:80px;display:inline-block;">明细类型：</span>
    <input id="type"  class="mini-combobox" style="width:155px;" data="typeStatus" value='<%= result.data[0].type %>'/>
    <br/><br/>

    <span style="width:80px;display:inline-block;">操作名称：</span>
    <input id="title" name="refundFee" class="mini-textbox" style="width:155px;"  value='<%= result.data[0].title %>'/>
    <input id="orderCode" name="orderNo" class="mini-textbox" style="display: none"  value='<%= result.data[0].orderCode%>'/>

    <br/><br/>

    <span style="width:80px;display:inline-block;">退款回复：</span>
    <textarea id="refundAnswer" class="mini-textarea" style="width: 400px;height: 50px" value='<%= result.data[0].refundAnswer %>'></textarea>

    <br/><br/>

    <span style="width:80px;display:inline-block;">退款原因：</span>
    <textarea id="refundReason" class="mini-textarea"  value="<%= result.data[0].refundReason%>" style="width: 400px;height: 100px"></textarea>

    <br/><br/>
    <div style="margin: 0 auto;text-align: center">
        <a class="mini-button " iconCls="icon-ok" onclick="updataRefund()">同意</a>
        <a class="mini-button " iconCls="icon-cancel" onclick="refundRefuse()">拒绝</a>
        <a class="mini-button" iconCls="icon-cancel" onclick="onCancel">取消</a>
    </div>
</div>
<!--<div id="datagrid1" class="mini-datagrid" style="width:99%;height: 92%;"-->
     <!--url="/getdata/shopOrder" idField="id" allowResize="true"-->
     <!--sizeList="[20,30,50,100]" pageSize="30"-->
     <!--onshowrowdetail="onShowRowDetail"-->
<!--&gt;-->
    <!--<div property="columns">-->
        <!--<div type="expandcolumn" >#</div>-->
        <!--<div field="objectId" width="120" headerAlign="center" allowSort="true">订单id-->
            <!--<input property="editor" class="mini-textbox" />-->
        <!--</div>-->
        <!--<div field="status" width="50" allowSort="true" renderer="statusRenderer" align="center" headerAlign="center">订单状态</div>-->
        <!--<div field="goodsPicURL" width="50" allowSort="true"  align="center" headerAlign="center">商品图片</div>-->
        <!--<div field="orderCode" width="100" align="center" headerAlign="center" allowSort="true">订单号</div>-->
        <!--<div field="totalPrice" width="50" align="center" headerAlign="center" allowSort="true">付款金额</div>-->
        <!--<div field="phone" width="100"  align="center" headerAlign="center" allowSort="true">电话号码</div>-->
        <!--<div field="shopName" width="100"  align="center" headerAlign="center" allowSort="true">店铺名称</div>-->
        <!--<div field="payType" width="100" align="center" headerAlign="center" renderer="payTypeRenderer" allowSort="true">支付方式</div>-->
        <!--<div field="receiver" width="100" align="center" headerAlign="center" allowSort="true" >收货人</div>-->
        <!--<div field="expressCode" width="100" align="center" headerAlign="center" allowSort="true" >快递编号</div>-->
        <!--<div field="logisticsCom" width="100" align="center" headerAlign="center" allowSort="true" >物流公司</div>-->
        <!--<div field="deliverTime" width="100" align="center" headerAlign="center" dateFormat="yyyy-MM-dd hh:mm:ss" allowSort="true">发货时间</div>-->
        <!--<div field="payTime" width="100" align="center" headerAlign="center" dateFormat="yyyy-MM-dd hh:mm:ss" allowSort="true">付款时间</div>-->
        <!--<div field="createdAt" width="100" align="center" headerAlign="center" dateFormat="yyyy-MM-dd hh:mm:ss" allowSort="true">创建日期</div>-->
    <!--</div>-->
<!--</div>-->
</body>
<script>
    var grid = mini.get("datagrid1");
    var shopStatus = [{ id: 1, text: '正常' }, { id: 0, text: '关闭'}];
    var typeStatus = [{id:1, text: '买家' },{id:2, text: '卖家' },{id:3, text: '系统' }];
    mini.parse();
    <!--var objectId = '<%= result.data[0].objectId%>';-->
    function updataRefund() {
        var orderCode = mini.get("orderCode").getValue();
        var form = new mini.Form("#form1");
        form.loading("退款中……");
        $.ajax({
            type: "POST",
            url: "/getdata/doWxRefund",
            data: {
                orderNo:orderCode,
            },
            success: function (result) {
                var rs = JSON.parse(result);
                if (rs.state==1) {
                    CloseWindow("save");
                }else{
                    alert("退款失败");
                    CloseWindow("save");
                }
            }
        })
    }
    function refundRefuse() {
        var orderCode = mini.get("orderCode").getValue();
        var form = new mini.Form("#form1");
        form.loading("退款中……");
        $.ajax({
            type: "POST",
            url: "/getdata/sysOrderRefundRefuse",
            data: {
                orderNo:orderCode,
            },
            success: function (result) {
                console.log(result);
                var rs = JSON.parse(result);
                console.log(rs);
                if (rs.state==1) {
                    CloseWindow("save");
                }else if(rs.state==0){
                    alert("拒绝失败");
                    CloseWindow("save");
                }else if(rs.state==2){
                    alert(rs.msg);
                    CloseWindow("save");
                }
            }
        })
    }
    //    关闭窗口
    function CloseWindow(action) {
        if (action == "close" && form.isChanged()) {
            if (confirm("数据被修改了，是否先保存？")) {
                return false;
            }
        }
        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
        else window.close();
    }
    function onOk(e) {
        SaveData();
    }
    function onCancel(e) {
        CloseWindow("cancel");
    }
</script>
</html>